/**
 * Copyright (c) 2007, Blue Hole Software. All rights reserved.
 * Code licensed under the Apache 2.0 License:
 * http://www.apache.org/licenses/
 */
package org.bhf.providers.security.authentication;

import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import java.util.Date;

/**
 * A security log captures the following events.
 * <dl>
 *  <dt>FAILED</dt><dd>Login attempt failed.</dd>
 *  <dt>SUCCEEDED</dt><dd>Login succeeded</dd>
 *  <dt>DISABLED</dt><dd>Accoutn as disabled (generally too many failed attempts)</dd>
 *  <dt>PASSWORDCHANGED</dt><dd>Password was changed</dd>
 * </dl>
 */
@Entity
@Table( name = "LOG" )
public class AuthenticationLog
{
    private long        id;
    private String      userID;
    private LogEvent    event;
    private Date        time   = new Date();

    @Id
    @GeneratedValue( strategy = GenerationType.AUTO )
    public long                     getId()
    {
        return id;
    }

    public void                     setId( final long id )
    {
        this.id = id;
    }

    public String                   getUserID()
    {
        return userID;
    }

    public void                     setUserID( final String userID )
    {
        this.userID = userID;
    }

    @Enumerated( EnumType.STRING )
    public LogEvent                 getEvent()
    {
        return event;
    }

    public void                     setEvent( final LogEvent event )
    {
        this.event = event;
    }

    @Temporal( TemporalType.TIMESTAMP )
    public Date                     getTime()
    {
        return time;
    }

    public void                     setTime( final Date time )
    {
        this.time = time;
    }
}
